Skip to content

feat(chrony): introducing the chrony module#2397

Draft
aafeijoo-suse wants to merge 4 commits into
dracut-ng:mainfrom
aafeijoo-suse:chrony-feat
Draft

feat(chrony): introducing the chrony module#2397
aafeijoo-suse wants to merge 4 commits into
dracut-ng:mainfrom
aafeijoo-suse:chrony-feat

Conversation

@aafeijoo-suse

Copy link
Copy Markdown
Contributor

This new module relies on chrony to add support for NTP in the initrd. By default, it also uses NTP sources from DHCP.

It provides two new kernel command line options:

  • rd.ntp: it can be used multiple times to specify server, pool and peer time sources.
  • rd.ntp.nodhcp: it disables the use of NTP sources from DHCP.

In some environments, it's necessary to fetch live images from HTTPS URLs. The problem is that the hardware clock may be off, so the validation of the SSL certificates may fail if the time is out of sync. Also, some systems may not have access to DHCP for security reasons, that's why we need a way to configure them on the kernel command line.

Notes:

  • chrony upstream only provides systemd services and configuration as examples, so there are many differences between the distributions.
  • While it might make sense to use /var on the host, let's try to use /run in the initrd, so everything can persist after switching root.

Checklist

  • I have tested it locally
  • I have reviewed and updated any documentation if relevant
  • I am providing new code and test(s) for it

@aafeijoo-suse aafeijoo-suse requested a review from a team as a code owner April 17, 2026 13:31
@github-actions github-actions Bot added modules Issue tracker for all modules systemd-networkd Issues related to the systemd-networkd module network-manager Issues related to the network-manager module github Issues related to .github man docs labels Apr 17, 2026
@devkontrol

Copy link
Copy Markdown
Collaborator

Would it be reasonable to add test case for this new dracut module ?

so the validation of the SSL certificates may fail

Does this happen already on the CI ? Can we trigger it with some test ?

@aafeijoo-suse

Copy link
Copy Markdown
Contributor Author

Would it be reasonable to add test case for this new dracut module ?

Upstream has 143 modules and 24 tests. There is already a module providing NTP without a test (well, systemd-timesyncd only provides simple NTP). I can't find a rule of thumb, some of the latest additions do not have a test: devicetree-firmware, memdisk, simpledrm, systemd-battery-check, hwdb, pcmcia, numlock, systemd-bsod... Furthermore, adding tests can take ages (see my PR adding tests for systemd-sysext).

so the validation of the SSL certificates may fail

Does this happen already on the CI ?

I don't think so. The real use case for this module is an OS installer image, downloaded remotely from the initrd. We need a way to specify NTP in the initrd before fetching the image over HTTPS, otherwise, in isolated systems with an out of sync clock the fetch may fail and the OS could not be installed.

Can we trigger it with some test ?

I guess an HTTPS server with an expired certificate could be simulated. But... I'm not sure if it makes sense to test this in the CI.

@devkontrol

Copy link
Copy Markdown
Collaborator

some of the latest additions do not have a test: devicetree-firmware, memdisk, simpledrm, systemd-battery-check, hwdb, pcmcia, numlock, systemd-bsod

None of these dracut modules maintain a dedicated .service file - they all just copy the .service file that is maintained by other project. This PR however introducing a new .service file (and .conf file) that this project would have to maintain.

Could we pick up the .service file and .conf file from the host instead ?

chrony upstream only provides systemd services and configuration as examples, so there are many differences between the distributions.

This PR suggests that dracut would now maintain distribution-independent service file without a test.

@aafeijoo-suse

Copy link
Copy Markdown
Contributor Author

None of these dracut modules maintain a dedicated .service file - they all just copy the .service file that is maintained by other project.

And that does not mean that they work with dracut, usually because dracut is not installing all required dependencies, binaries, kernel modules, configuration... Also, there are some dracut modules that install modified versions of systemd services via sed without a test (bluetooth, dbus-daemon, dbus-broker).

This PR however introducing a new .service file (and .conf file) that this project would have to maintain.
Could we pick up the .service file and .conf file from the host instead ?

No, we can't, for the reasons explained in the notes of the PR description, plus although the systemd services were the same on the host in all distros, they are not implemented to work in the initrd (the Install section cannot be overridden and it has a WantedBy=multi-user.target).

This PR suggests that dracut would now maintain distribution-independent service file without a test.

I don't see why that is a big deal here, most of the merged code is not being tested. But anyway, I'll add one test if that is the only objection to this PR.

@Conan-Kudo

Copy link
Copy Markdown
Collaborator

I would prefer some tests for this module, please.

@bdrung

bdrung commented Apr 30, 2026

Copy link
Copy Markdown
Member

I would like to see code tested as well: either get those services upstream and test it there; or add a test case in dracut.

@github-actions github-actions Bot added the test Issues related to testing label Apr 30, 2026
@aafeijoo-suse aafeijoo-suse marked this pull request as draft April 30, 2026 13:40
@aafeijoo-suse

Copy link
Copy Markdown
Contributor Author

Draft until the CI has #2418

Comment thread test/TEST-61-CHRONY/test.sh Fixed
Comment thread test/TEST-61-CHRONY/test.sh Fixed
@aafeijoo-suse aafeijoo-suse force-pushed the chrony-feat branch 2 times, most recently from 75bc0be to 3bf6088 Compare April 30, 2026 14:43
@devkontrol

Copy link
Copy Markdown
Collaborator

There is already a module providing NTP without a test

I think this is not the case as TEST-41 includes systemd-network-management, which than includes systemd-timesyncd. Perhaps NTP functionality is not tested/confirmed, but at the CI would break without systemd-timesyncd

aafeijoo-suse added a commit to openSUSE/dracut-ng that referenced this pull request May 11, 2026
aafeijoo-suse added a commit to openSUSE/dracut-ng that referenced this pull request May 11, 2026
aafeijoo-suse added a commit to openSUSE/dracut-ng that referenced this pull request May 11, 2026
This new module relies on chrony to add support for NTP in the initrd. By
default, it also uses NTP sources from DHCP.

It provides two new kernel command line options:
- `rd.ntp`: it can be used multiple times to specify server, pool and peer time
sources.
- `rd.ntp.nodhcp`: it disables the use of NTP sources from DHCP.

In some environments, it's necessary to fetch live images from HTTPS URLs. The
problem is that the hardware clock may be off, so the validation of the SSL
certificates may fail if the time is out of sync. Also, some systems may not
have access to DHCP for security reasons, that's why we need a way to configure
them on the kernel command line.

jsc#PED-16110

(cherry picked from dracut-ng#2397)
aafeijoo-suse added a commit to openSUSE/dracut that referenced this pull request May 11, 2026
aafeijoo-suse added a commit to openSUSE/dracut that referenced this pull request May 11, 2026
This new module relies on chrony to add support for NTP in the initrd. By
default, it also uses NTP sources from DHCP.

It provides two new kernel command line options:
- `rd.ntp`: it can be used multiple times to specify server, pool and peer time
sources.
- `rd.ntp.nodhcp`: it disables the use of NTP sources from DHCP.

In some environments, it's necessary to fetch live images from HTTPS URLs. The
problem is that the hardware clock may be off, so the validation of the SSL
certificates may fail if the time is out of sync. Also, some systems may not
have access to DHCP for security reasons, that's why we need a way to configure
them on the kernel command line.

jsc#PED-16110

(cherry picked from dracut-ng/dracut#2397)
aafeijoo-suse added a commit to openSUSE/dracut-ng that referenced this pull request May 12, 2026
aafeijoo-suse added a commit to openSUSE/dracut-ng that referenced this pull request May 12, 2026
This new module relies on chrony to add support for NTP in the initrd. By
default, it also uses NTP sources from DHCP.

It provides two new kernel command line options:
- `rd.ntp`: it can be used multiple times to specify server, pool and peer time
sources.
- `rd.ntp.nodhcp`: it disables the use of NTP sources from DHCP.

In some environments, it's necessary to fetch live images from HTTPS URLs. The
problem is that the hardware clock may be off, so the validation of the SSL
certificates may fail if the time is out of sync. Also, some systems may not
have access to DHCP for security reasons, that's why we need a way to configure
them on the kernel command line.

jsc#PED-16110

(cherry picked from dracut-ng#2397)
aafeijoo-suse added a commit to openSUSE/dracut-ng that referenced this pull request May 12, 2026
aafeijoo-suse added a commit to openSUSE/dracut-ng that referenced this pull request May 12, 2026
This new module relies on chrony to add support for NTP in the initrd. By
default, it also uses NTP sources from DHCP.

It provides two new kernel command line options:
- `rd.ntp`: it can be used multiple times to specify server, pool and peer time
sources.
- `rd.ntp.nodhcp`: it disables the use of NTP sources from DHCP.

In some environments, it's necessary to fetch live images from HTTPS URLs. The
problem is that the hardware clock may be off, so the validation of the SSL
certificates may fail if the time is out of sync. Also, some systems may not
have access to DHCP for security reasons, that's why we need a way to configure
them on the kernel command line.

jsc#PED-16110

(cherry picked from dracut-ng#2397)
aafeijoo-suse added a commit to openSUSE/dracut-ng that referenced this pull request May 12, 2026
aafeijoo-suse added a commit to openSUSE/dracut-ng that referenced this pull request May 12, 2026
This new module relies on chrony to add support for NTP in the initrd. By
default, it also uses NTP sources from DHCP.

It provides two new kernel command line options:
- `rd.ntp`: it can be used multiple times to specify server, pool and peer time
sources.
- `rd.ntp.nodhcp`: it disables the use of NTP sources from DHCP.

In some environments, it's necessary to fetch live images from HTTPS URLs. The
problem is that the hardware clock may be off, so the validation of the SSL
certificates may fail if the time is out of sync. Also, some systems may not
have access to DHCP for security reasons, that's why we need a way to configure
them on the kernel command line.

jsc#PED-16110

(cherry picked from dracut-ng#2397)
aafeijoo-suse added a commit to openSUSE/dracut-ng that referenced this pull request May 12, 2026
This new module relies on chrony to add support for NTP in the initrd. By
default, it also uses NTP sources from DHCP.

It provides two new kernel command line options:
- `rd.ntp`: it can be used multiple times to specify server, pool and peer time
sources.
- `rd.ntp.nodhcp`: it disables the use of NTP sources from DHCP.

In some environments, it's necessary to fetch live images from HTTPS URLs. The
problem is that the hardware clock may be off, so the validation of the SSL
certificates may fail if the time is out of sync. Also, some systems may not
have access to DHCP for security reasons, that's why we need a way to configure
them on the kernel command line.

jsc#PED-16110

(cherry picked from dracut-ng#2397)
imobachgs added a commit to agama-project/agama that referenced this pull request May 13, 2026
> [!NOTE]
> It is still a work in progress.

This PR introduces support for reading setting the NTP configuration
through kernel command-line option.

1. Adds the new [chrony dracut
module](dracut-ng/dracut#2397).
2. Reads the time sources from dracut (located in
`/run/chrony/dracut.sources.d/dracut.sources`). They will be included as
part of the "extended configuration" (just like we do with the
`inst.register_url` argument).

## Testing

- [x] Added a new unit test
- [x] Tested manually
The first argument will define the server type: HTTP or HTTPS.
The second argument will get the name of the certificate required for HTTPS.
This new module relies on chrony to add support for NTP in the initrd. By
default, it also uses NTP sources from DHCP.

It provides two new kernel command line options:
- `rd.ntp`: it can be used multiple times to specify server, pool and peer time
sources.
- `rd.ntp.nodhcp`: it disables the use of NTP sources from DHCP.

In some environments, it's necessary to fetch live images from HTTPS URLs. The
problem is that the hardware clock may be off, so the validation of the SSL
certificates may fail if the time is out of sync. Also, some systems may not
have access to DHCP for security reasons, that's why we need a way to configure
them on the kernel command line.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

docs github Issues related to .github man modules Issue tracker for all modules network-manager Issues related to the network-manager module systemd-networkd Issues related to the systemd-networkd module test Issues related to testing

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants